package com.education.service.task;

import java.util.HashMap;

/**
 * 封装任务的参数类
 * @author 余一
 * @Description
 * @date 2021/6/13 12:12
 */
public class TaskParam extends HashMap {
    private Class<? extends TaskListener> taskListenerClass;
    private final long timestamp;
    private Object data;

    public TaskParam() {
        this.timestamp = System.currentTimeMillis();
    }

    public TaskParam(Class<? extends TaskListener> taskListenerClass) {
        this(taskListenerClass,System.currentTimeMillis(),null);
    }

    public TaskParam(Class<? extends TaskListener> taskListenerClass, Object data) {
        this(taskListenerClass,System.currentTimeMillis(),data);
    }

    public TaskParam(Class<? extends TaskListener> taskListenerClass, long timestamp, Object data) {
        this.taskListenerClass = taskListenerClass;
        this.timestamp = timestamp;
        this.data = data;
    }

    public Class<? extends TaskListener> getTaskListenerClass() {
        return taskListenerClass;
    }

    public void setTaskListenerClass(Class<? extends TaskListener> taskListenerClass) {
        this.taskListenerClass = taskListenerClass;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public <T> T getData() {
        return (T)data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
